# coding:utf-8
from django.db import models
from django.contrib import admin
from django.contrib.admin.models import User

# 相册
class Photo(models.Model):
    user = models.ForeignKey(User)
    img = models.ImageField(upload_to='images/album',default='images/album')
    title = models.CharField(max_length=100,blank=True,default='From ChiWood')
    create_time = models.DateTimeField(auto_now_add=True,blank=True)
    modify_time = models.DateTimeField(auto_now=True,blank=True)

    def __unicode__(self):
        return self.title

# 档期
class Schedule(models.Model):
    user = models.ForeignKey(User)
    begin_time = models.DateTimeField()
    end_time = models.DateTimeField()
    note = models.CharField(max_length=60)
    def __unicode__(self):
        return self.note

class Voice(models.Model):
    user = models.OneToOneField(User)
    file_path = models.FileField(upload_to='voice/')
    title = models.CharField(max_length=60)
    def __unicode__(self):
        return self.title


# 用户模型
class UserProfile(models.Model):
    user = models.ForeignKey(User, unique=True)
    avatar = models.ImageField(blank=True,upload_to='images/avatar/')
    # album = models.ForeignKey(Photo,blank=True,default=Photo.objects.create(img='/images/album/1.png',title='From ChiWood'))
    collection  = models.ManyToManyField(User,related_name='focus',blank=True)
    fans = models.ManyToManyField(User,related_name='fans',blank=True)

    nick_name = models.CharField(u'昵称',max_length=30)
    phone = models.CharField(u'手机号',max_length=11)
    birthday = models.DateField(u'生日')
    height = models.CharField(u'身高',max_length=10)
    gender = models.CharField(u'性别',max_length=6)
    sign = models.CharField(u'签名',max_length=150,null=True,blank=True)
    age = models.IntegerField()
    def __unicode__(self):
        return u'Profile of user: %s' % self.user.username

admin.site.register(UserProfile)
admin.site.register(Schedule)
admin.site.register(Voice)
admin.site.register(Photo)